/*
** File name:		window_menu_user_manages.c
** Brief: 
** COPYRIGHT(C) gkt 2021 
** ------------------------------------------------------- 
** Module Information: 
** 
** Revision History -------------------------------------- 
** ------------------------------------------------------- 
**	Date 		Version		Action				Author   
** ------------------------------------------------------- 
**	2021-1-12 	1.0			Created				liwenjie   
** 
*/ 

/* Includes -----------------------------------------------------*/
#include "window_common.h"

/* Global Variables ---------------------------------------------*/
/* Macro --------------------------------------------------------*/
enum {
	WIDGET_ID_USER_MANAGE_TITLE,
	WIDGET_ID_USER_MANAGE_LIST,
	WIDGET_ID_MAX
};

static const gkt_widget_list_item_s sc_window_user_manage_widget_list_items[] = {
	GKT_WIDGET_LIST_STATIC_ITEM(WINDOW_TEXT_ID_add_user, WINDOW_ID_user_add_auth),
	GKT_WIDGET_LIST_STATIC_ITEM(WINDOW_TEXT_ID_delete_user, WINDOW_ID_user_delete),
};

static const gkt_widget_list_attr_s sc_window_user_manage_widget_list_attr = 
	GKT_WIDGET_LIST_STATIC_ATTR(WINDOW_WIDGET_NORMAL_HEIGHT, 
			sizeof(sc_window_user_manage_widget_list_items) / sizeof(gkt_widget_list_item_s),
			sc_window_user_manage_widget_list_items);

GKT_WINDOW_WIDGET_DESCS_DEFINE(user_manage) = {
	[WIDGET_ID_USER_MANAGE_TITLE] = GKT_WIDGET_LABEL_DESC(
			GKT_WIDGET_F_ALIGN_MIDDLE | GKT_WIDGET_F_TITLE_MARK,
			WINDOW_FONT_NORMAL_SIZE, 
			WINDOW_TITLE_FG_COLOR, WINDOW_TITLE_BG_COLOR,
			0, 0, 
			WINDOW_WIDGET_DEFAULT_WIDTH, WINDOW_WIDGET_NORMAL_HEIGHT,
			WINDOW_TEXT_ID_user_manage),
	
	[WIDGET_ID_USER_MANAGE_LIST] = GKT_WIDGET_LIST_DESC(
			GKT_WIDGET_F_FOCUSABLE | GKT_WIDGET_F_ALIGN_MIDDLE,
			WINDOW_FONT_NORMAL_SIZE, 
			WINDOW_DEFAULT_FG_COLOR, WINDOW_DEFAULT_BG_COLOR,  
			0, WINDOW_WIDGET_NORMAL_HEIGHT, 
			WINDOW_WIDGET_DEFAULT_WIDTH, WINDOW_WIDGET_NORMAL_HEIGHT*(WINDOW_NORMAL_ROWS - 1),
			&sc_window_user_manage_widget_list_attr),
};

/* Extern Functions ---------------------------------------------*/
/* Static Functions ---------------------------------------------*/
/* Functions ----------------------------------------------------*/

static int window_user_manage_event_handler(
				uint32_t major_type, uint32_t minor_type, 
				uint32_t id, uint32_t data)
{
	int retval = GKT_EVENT_HANDLE_CONTINUE;
	gkt_window_id_t window_id;
 	
	switch (major_type) {
		case GKT_EVENT_WINDOW:
			if (GKT_WINDOW_ACTIVE == minor_type)
				window_common_mask_except_updn_cancel_ok();
			break;
		case GKT_EVENT_WIDGET: 
			if (GKT_WIDGET_EVENT_CLICK == minor_type) {
				window_id = (gkt_window_id_t)sc_window_user_manage_widget_list_items[data].data;
				gkt_window_show(window_id, 0);
			}
			retval = GKT_EVENT_HANDLE_COMPLETE;
			break;
		default:
			break;
	}	
	return retval;
}

/* Functions ----------------------------------------------------*/
GKT_WINDOW_DESC_DEFINE(user_manage); 

